# Contributor: Henrik Riomar <henrik.riomar@gmail.com>
# Contributor: Drew DeVault <sir@cmpwn.com>
# Maintainer: Michał Polański <michal@polanski.me>
pkgname=swaylock
pkgver=1.6
pkgrel=0
pkgdesc="Screen locker for Wayland"
url="https://swaywm.org/"
license="MIT"
arch="all"
makedepends="cairo-dev
	gdk-pixbuf-dev
	libxkbcommon-dev
	linux-pam-dev
	meson
	ninja
	scdoc
	wayland-dev
	wayland-protocols
	"
provider_priority=100  # highest (other provider is swaylock-effects)
install="$pkgname.post-install $pkgname.post-upgrade"
subpackages="
	$pkgname-dbg
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/swaywm/swaylock/archive/$pkgver.tar.gz
	ungit-version.patch
	"
options="!check" # no test suite

# secfixes:
#   1.6-r0:
#     - CVE-2022-26530

prepare() {
	default_prepare
	sed -i 's/login/base-auth/g' \
		pam/swaylock

	cat <<-__EOF__ >> pam/swaylock

	# Unlock GNOME Keyring if available
	-auth       optional     pam_gnome_keyring.so
	-session    optional     pam_gnome_keyring.so auto_start

	# Unlock KWallet if available
	-auth    optional        pam_kwallet.so
	-auth    optional        pam_kwallet5.so
	-session optional        pam_kwallet.so auto_start
	-session optional        pam_kwallet5.so auto_start
	__EOF__

}

build() {
	abuild-meson . output
	meson compile -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output

	mv "$pkgdir"/usr/share/fish/vendor_completions.d "$pkgdir"/usr/share/fish/completions
}

sha512sums="
9a472c25e53a41c461af41af31c7fc8b275754628d0b20f4e5085cd7ca514e68361293a6e93fb6fcb7632419a3c73e4578e03294af28fe62d944cc43339f280d  swaylock-1.6.tar.gz
abcd88c5f8bc98a6c4f0c0e5bab11a37ce02da66dc3cdc4c6557acd5d885bdbbeb5d394ac104effbeb5f76e247c587df7c728353163e330bf615c1ec5d2f1170  ungit-version.patch
"
